		
		<%@page import="java.util.Date"%>
		<%@page import="java.text.SimpleDateFormat"%>
		<%@page import="net.sf.jasperreports.engine.export.JRHtmlExporter"%>
		<%@page import="java.io.File"%>
		<%@page import="java.util.List"%>
		<%@page import="java.io.*"%>
		<%@page import="net.sf.jasperreports.engine.JasperExportManager"%>
		<%@page import="java.io.OutputStream"%>
		<%@page import="net.sf.jasperreports.engine.export.JRPdfExporterParameter"%>
		<%@page import="net.sf.jasperreports.engine.JRExporterParameter"%>
		<%@page import="net.sf.jasperreports.engine.export.JRPdfExporter"%>
		<%@page import="net.sf.jasperreports.engine.JasperPrint"%>
		<%@page import="net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter"%>
		<%@page import="net.sf.jasperreports.engine.export.JRXlsExporterParameter"%>
		<%@page import="net.sf.jasperreports.engine.export.HtmlExporter"%>
		<%@page import="net.sf.jasperreports.engine.export.JRHtmlExporterParameter"%>
		<%@page import="net.sf.jasperreports.engine.*"%>
		<%@page import="net.sf.jasperreports.engine.export.*"%>
		<%@page import="net.sf.jasperreports.engine.design.*" %>
		<%@page import="net.sf.jasperreports.j2ee.servlets.*" %>
		<%
		
			
		try{
			SimpleDateFormat l_format = new SimpleDateFormat("yyyy-MM-dd-hh-mm");
			if(request.getParameter("title") != null) {
				if(request.getSession().getAttribute(request.getParameter("title") + request.getParameter("id")) == null)
					request.getSession().setAttribute(request.getParameter("title") + request.getParameter("id"), (JasperPrint)request.getSession().getAttribute("report_data"));
			}
			request.getSession().removeAttribute("report_data");
			JasperPrint jasperPrint = (JasperPrint)request.getSession().getAttribute(request.getParameter("title") + request.getParameter("id"));
			
			JRXlsxExporter xlsxExporter = new JRXlsxExporter();
			//JRExporter xlsxExporter = new JExcelApiExporter();
			 ByteArrayOutputStream os = new ByteArrayOutputStream();
			 
			 xlsxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
			 xlsxExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, l_format.format(new Date()) + ".xlsx");
			 
			 //uncomment this codes if u are want to use servlet output stream
			 //xlsxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletOutputStream);
			 
			 xlsxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);

			 
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER, Boolean.FALSE);
			 //xlsxExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
			 //xlsxExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.FALSE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
			 xlsxExporter.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.FALSE);
			 
			 xlsxExporter.exportReport();
			 
			 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			 response.setHeader("Content-Disposition", "attachment; filename=" + l_format.format(new Date()) + ".xlsx");
			 
			 //uncomment this codes if u are want to use servlet output stream
			 //servletOutputStream.write(os.toByteArray());
			 
			 response.getOutputStream().write(os.toByteArray());
			 response.getOutputStream().flush();
			 response.getOutputStream().close();
			 response.flushBuffer();
		
		}catch (Exception e) {
	           System.out.print("Exceptiion" + e);
	      }			
	%>	
		
		
			 